package com.oocl.crm.util;

import java.io.OutputStream;

import com.oocl.crm.pojo.Customer;

public class FormatPrinter {
	public static void printHelpDoc(String cmd, OutputStream out){
		String[] subCmdString = cmd.split(" ");
		String help ;
		if(subCmdString.length ==2){
			switch(subCmdString[1].toUpperCase()){
			case "L":
				help = "使用命令‘L’查詢所有人员信息 \r使用‘L id:1’查询指定id人员信息\r使用’使用L name:messi,sex:男‘查询名字为messi性别为男的信息";
				break;
			case "A":
				help = "使用命令’A name:evan,call:123‘参数任意的信息添加人员信息\r";
				break;
			case "D":
				help = "D id:1"+"删除id为1的人员信息"+ "\r";
				break;
			case "U":
				help ="U id:234,name:Neal" + "\r"
						+ "U id:234,name:Wintom,call:136**" + "\r"+"给出id和部分参数并更新指定参数的内容";
				break;
			case "O":
				help ="O id" + "\r"
						+"O name" + "\r"
						+"选择按id排序还是用名字排序";
				break;
			case "H":
				help ="H" +"查询帮助信息"+ "\r"
						+ "H A" +"查询具体帮助信息"+ "\r";
				break;
			case "Q":
				help ="退出程序" + "\r";
				break;
			default:
				help ="命令有误";
			}
		}else{
			help = "the basic usage is like this:"+"\r"
					+ "command [L for retrieve, A for Add, D for delete, U for update, O for sort, H for help, Q for quit]" +"\r"
					+ "for example:" + "\r"
					+ "L " + "\r"
					+ "L id:1" + "\r"
					+ "L name:evan,sex:man" + "\r"
					+ "A name:Cristiano,sex:Male,birthday:2017-01-01,adrress:zhuhai,call:123" + "\r"
					+ "D id:123" + "\r"
					+ "U id:234,name:Neal" + "\r"
					+ "U id:234,name:Wintom,call:136**" + "\r"
					+ "O id"+ "\r"
					+ "O name"+ "\r"
					+ "H" + "\r"
					+ "H A" + "\r"
					+ "Q" + "\r";
		}
		
		System.out.println(help);
	}

	public static void printCustomers(Customer[] cs,OutputStream out){
		for(int i = 0; i<cs.length;i++){
			System.out.println(cs[i]);
		}
	}
}
